let search = $('.sea')[0]
let ul = $('.search-ul')[0]
ul.style.display = 'none'
search.onkeyup = () => {
    ul.innerHTML = ''
    ul.style.display = 'none'
    const ipt = search.value
    let wd = ipt
    if (wd.trim().length == 0) {
        ul.innerText = ''
        return
    }
    $.ajax({
        url: `https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?&wd=${wd}`,
        type: 'get',
        dataType: 'jsonp',
        success(res) {
            let data = res.s
            data.forEach(item => {
                ul.innerHTML += `
                            <li>${item}</li>
                            `
                         });
            ul.style.display = 'block'
            if (!data.length) {
                ul.style.display = 'none'
            }

        },
        jsonp: 'cb'

    })
}

document.onclick = () => {
    let res = ul.style.display
    if (res == 'block') {
        ul.style.display = 'none'
    }
}